<div id="house-detail-view">
  <div class="page">
    <div class="button-container" ng-if="house">
      <button class="btn btn-primary" ng-if="house.status==1"
              ng-click="doOffCheckIn()">线下入住</button>
      <button class="btn btn-success" ng-if="house.status==1"
              ng-click="doEarnest()">交定金</button>
      <button class="btn btn-danger" ng-if="house.status==8 && contract && contract.status==2"
              ng-click="doRevokeContract()">撤销合同</button>
      <button class="btn btn-success" ng-if="house.status==8 && house.depositBillId"
              ng-click="earnestCheckIn()">定金入住</button>
      <button class="btn btn-primary" ng-if="house.status==8 && contract && contract.status==4"
              ng-click="doOnCheckIn()">线上入住</button>
      <button class="btn btn-success" ng-if="isRenting() && contract.nextLeaseTime"
              ng-click="payLease()">缴租</button>
      <!--<button class="btn btn-danger" ng-if="isRenting() && needWarn()"-->
              <!--ng-confirm-click="{{warnSMS(item)}}"-->
              <!--ng-click="doPress()">催款</button>-->
      <button class="btn btn-success" ng-if="isRenting()"
              ng-click="rechargePower()">水电充值</button>
      <button class="btn btn-info" ng-if="isRenting() && noOwningBill()"
              ng-click="doRelet()">续租</button>
      <button class="btn btn-primary" ng-if="isRenting() && noOwningBill()"
              ng-click="changeHouse()">换房</button>
      <button class="btn btn-warning" ng-if="isRenting() && noOwningBill()"
              ng-click="doSublet()">转租</button>
      <button class="btn btn-danger" ng-if="isRenting() || (house.status==8 && contract && contract.status==4)"
              ng-click="doOffLease()">退租</button>
      <button class="btn btn-warning al-fl-rt" ng-click="refreshData()">刷新</button>
    </div>
    <div class="house-info-container" style="border-bottom: 1px solid #aaa">
      <ng-form class="form-horizontal" ng-if="house">
        <div class="form-group">
          <h3 class="text-center">房间信息</h3>
        </div>
        <div class="form-group">
          <label class="control-label col-sm-2 col-sm-offset-1">公寓</label>
          <div class="col-sm-3">
            <div class="form-control info-text">{{house.apartmentName}}</div>
          </div>
          <label class="control-label col-sm-2">楼栋</label>
          <div class="col-sm-3">
            <div class="form-control info-text">{{house.buildingName}}</div>
          </div>
        </div>
        <div class="form-group">
          <label class="control-label col-sm-2 col-sm-offset-1">房间号</label>
          <div class="col-sm-3">
            <div class="form-control info-text">{{house.houseNo}}</div>
          </div>
          <label class="control-label col-sm-2">状态</label>
          <div class="col-sm-3">
            <div class="form-control info-text">{{house.statusName}}</div>
          </div>
        </div>
        <div class="form-group">
          <label class="control-label col-sm-2 col-sm-offset-1">月租金</label>
          <div class="col-sm-3">
            <div class="form-control info-text">{{house.salePrice}}</div>
          </div>
          <label class="control-label col-sm-2">押金</label>
          <div class="col-sm-3">
            <div class="form-control info-text">{{house.depositPrice}}</div>
          </div>
        </div>
        <div class="form-group">
          <label class="control-label col-sm-2 col-sm-offset-1">付款方式</label>
          <div class="col-sm-3">
            <div class="form-control info-text">{{house.payType|binConstantTransfer:housePayTypeList}}</div>
          </div>
          <label class="control-label col-sm-2">房型</label>
          <div class="col-sm-3">
            <div class="form-control info-text">{{house.layoutName}}</div>
          </div>
        </div>
        <div class="form-group">
          <label class="control-label col-sm-2 col-sm-offset-1">面积</label>
          <div class="col-sm-3">
            <div class="form-control info-text">{{house.area}}</div>
          </div>
          <label class="control-label col-sm-2">朝向</label>
          <div class="col-sm-3">
            <div class="form-control info-text">{{house.orientationsName}}</div>
          </div>
        </div>
      </ng-form>
    </div>
    <div class="contract-info-container" ng-if="contract">
      <ng-form class="form-horizontal">
        <div class="form-group">
          <h3 class="text-center">合同信息</h3>
          <div ng-class="{true:'text-red',false:'text-blue'}[needWarn()]"
               class="text-center" >{{showLeaseInfo()}}</div>
        </div>
        <div class="form-group">
          <label class="control-label col-sm-2 col-sm-offset-1">合同号</label>
          <div class="col-sm-3">
            <div class="form-control info-text link-text"
                 wf-go-state="{{({state:'contract-detail',contractId:contract.id})}}"
                 ng-click="goContractDetail()">{{contract.uuid}}</div>
          </div>
          <label class="control-label col-sm-2">合同状态</label>
          <div class="col-sm-3">
            <div class="form-control info-text">{{contract.statusName}}</div>
          </div>
        </div>
        <div class="form-group">
          <label class="control-label col-sm-2 col-sm-offset-1">租期</label>
          <div class="col-sm-3">
            <div class="form-control info-text">{{contract.leaseName}}</div>
          </div>
          <label class="control-label col-sm-2">付款方式</label>
          <div class="col-sm-3">
            <div class="form-control info-text">{{contract.payWayName}}</div>
          </div>
        </div>
        <div class="form-group">
          <label class="control-label col-sm-2 col-sm-offset-1">合同月租金</label>
          <div class="col-sm-3">
            <div class="form-control info-text">{{contract.rental}}</div>
          </div>
          <label class="control-label col-sm-2">合同押金</label>
          <div class="col-sm-3">
            <div class="form-control info-text">{{contract.deposit}}</div>
          </div>
        </div>
        <div class="form-group">
          <label class="control-label col-sm-2 col-sm-offset-1">签署日期</label>
          <div class="col-sm-3">
            <div class="form-control info-text">{{contract.signTime}}</div>
          </div>
          <label class="control-label col-sm-2"
                 ng-if="contract.preContractUuid">原合同号</label>
          <div class="col-sm-3">
            <div class="form-control info-text"
                 ng-if="contract.preContractUuid">{{contract.preContractUuid}}</div>
          </div>
        </div>
        <div class="form-group">
          <label class="control-label col-sm-2 col-sm-offset-1">合同开始日期</label>
          <div class="col-sm-3">
            <div class="form-control info-text">{{contract.leaseStart|dateTransfer:'YYYY-MM-DD'}}</div>
          </div>
          <label class="control-label col-sm-2">合同结束日期</label>
          <div class="col-sm-3">
            <div class="form-control info-text">{{contract.leaseEnd|dateTransfer:'YYYY-MM-DD'}}</div>
          </div>
        </div>
        <div class="form-group">
          <label class="control-label col-sm-2 col-sm-offset-1">上次缴租时间</label>
          <div class="col-sm-3">
            <div class="form-control info-text">{{contract.lastLeaseTime|dateTransfer:'YYYY-MM-DD'}}</div>
          </div>
          <label class="control-label col-sm-2"
                 ng-class="{'text-red':needWarn()}">下次缴租时间</label>
          <div class="col-sm-3">
            <div class="form-control info-text">{{contract.nextLeaseTime|dateTransfer:'YYYY-MM-DD'}}</div>
          </div>
        </div>
        <div class="form-group">
          <label class="control-label col-sm-2 col-sm-offset-1">电费余额</label>
          <div class="col-sm-3">
            <div class="form-control info-text">{{contract.powerBalance}}</div>
          </div>
          <label class="control-label col-sm-2">水费余额</label>
          <div class="col-sm-3">
            <div class="form-control info-text">{{contract.waterBalance}}</div>
          </div>
        </div>
        <div class="form-group">
          <label class="control-label col-sm-2 col-sm-offset-1">承租人</label>
          <div class="col-sm-3">
            <div class="form-control info-text">{{contract.customerName}}</div>
          </div>
          <label class="control-label col-sm-2">手机号</label>
          <div class="col-sm-3">
            <div class="form-control info-text">{{contract.customerPhone}}</div>
          </div>
        </div>
        <div class="form-group">
          <label class="control-label col-sm-2 col-sm-offset-1">身份证</label>
          <div class="col-sm-3">
            <div class="form-control info-text">{{contract.customerCard}}</div>
          </div>
          <label class="control-label col-sm-2">性别</label>
          <div class="col-sm-3">
            <div class="form-control info-text">{{contract.sex|constantTransfer:sexList}}</div>
          </div>
        </div>
        <div class="form-group">
          <label class="control-label col-sm-2 col-sm-offset-1">居住人数</label>
          <div class="col-sm-3">
            <div class="input-group">
              <input type="number" class="form-control" readonly ng-model="contract.cotenants.length"
                     maxlength="4">
              <span class="input-group-addon" ng-click="openCotenant('view',contract.cotenants)">查看</span>
            </div>
          </div>
        </div>
        <div class="form-group">
          <label class="control-label col-sm-2 col-sm-offset-1">水费单价</label>
          <div class="col-sm-3">
            <div class="form-control info-text">{{contract.waterPrice}}</div>
          </div>
          <label class="control-label col-sm-2">电费单价</label>
          <div class="col-sm-3">
            <div class="form-control info-text">{{contract.powerPrice}}</div>
          </div>
        </div>
        <div class="form-group">
          <label class="control-label col-sm-2 col-sm-offset-1">业务员</label>
          <div class="col-sm-3">
            <div class="form-control info-text">{{contract.receptionist}}</div>
          </div>
          <label class="control-label col-sm-2">渠道</label>
          <div class="col-sm-3">
            <div class="form-control info-text">{{contract.buzTypeName}}</div>
          </div>
        </div>
        <div class="form-group">
          <label class="control-label col-sm-2 col-sm-offset-1">物业费</label>
          <div class="col-sm-3">
            <div class="form-control info-text">{{contract.manageFee}}</div>
          </div>
          <label class="control-label col-sm-2">合同备注</label>
          <div class="col-sm-3">
            <textarea class="form-control" rows="3" ng-readonly="true">{{contract.contractPicture}}</textarea>
          </div>
        </div>
        <div class="form-group">
          <div class="col-sm-4"></div>
          <div class="col-sm-4 text-center">
            <button class="btn btn-warning"
                    ng-click="printContract()">合同打印</button>
          </div>
        </div>
      </ng-form>
    </div>
    <div class="contract-info-container" ng-if="earnest">
      <ng-form class="form-horizontal">
        <div class="form-group">
          <h3 class="text-center">定金信息</h3>
        </div>
        <div class="form-group">
          <label class="control-label col-sm-2 col-sm-offset-1">预订手机号</label>
          <div class="col-sm-3">
            <div class="form-control info-text">{{earnest.customerPhone}}</div>
          </div>
          <label class="control-label col-sm-2">定金金额</label>
          <div class="col-sm-3">
            <div class="form-control info-text">{{earnest.payMoney}}</div>
          </div>
        </div>
        <div class="form-group">
          <label class="control-label col-sm-2 col-sm-offset-1">计划入住日期</label>
          <div class="col-sm-3">
            <div class="form-control info-text">{{earnest.startTime|dateTransfer:'YYYY-MM-DD'}}</div>
          </div>
          <label class="control-label col-sm-2">付款方式</label>
          <div class="col-sm-3">
            <div class="form-control info-text">{{earnest.payType|constantTransfer:allPayTypeList}}</div>
          </div>
        </div>
        <div class="form-group">
          <label class="control-label col-sm-2 col-sm-offset-1">预订时间</label>
          <div class="col-sm-3">
            <div class="form-control info-text">{{earnest.payTime|dateTransfer:'YYYY-MM-DD HH:mm:ss'}}</div>
          </div>
          <label class="control-label col-sm-2">定金备注</label>
          <div class="col-sm-3">
            <textarea cols="4" class="form-control" readonly ng-model="earnest.moneyDesc"></textarea>
          </div>
        </div>
    </ng-form>
  </div>
  </div>
</div>